package 剑指Offer.easy;

public class 在排序数组中查找数字1 {
    class Solution {
        public int search(int[] nums, int target) {
            int count = 0;
            int i = 0;
            while (i < nums.length && nums[i] < target) i++;
            if (i >= nums.length) return count;
            for (int j = i; j < nums.length; j++) {
                if (nums[j] == target) count++;
                else break;
            }
            return count;
        }
    }
}
